package cranix.board.bc;

import cranix.board.dao.CodeDao;
import cranix.common.util.Box;

public class CodeWriteBc extends DefaultBc {
	public CodeWriteBc(Box<String, Object> inputBox) throws Exception {
		super(inputBox);
	}

	@Override
	protected Box<String, Object> executeArea() throws Exception {
		Box<String,Object> input = getInputBox().getBox("paramBox");
		Box<String,Object> result = new Box<String,Object>("resultBox");
		CodeDao cd = new CodeDao(this);
		int cnt = 0;
		String mode = null;
		if (input.contains("seq")) {
			cnt = cd.updateCode();
			mode = "update";
		}
		else {
			cnt = cd.insertCode();
			mode = "insert";
		}
		result.put("mode",mode);
		result.put("count",cnt);
		
		return result;
	}
}
